package com.gm.tool.utils;


import com.google.gson.Gson;

/**
 * Created by mouse on 2016/8/31.
 */
public class JsonUtil {

    public static String getJsonString(Object entity) {
        return (new Gson()).toJson(entity);
    }

    public static <T> T getEntity(String jsonString, Class<T> cls) {
        return (new Gson()).fromJson(jsonString, cls);
    }

    public static <T> T object2Entity(Object obj, Class<T> cls) {
        return getEntity(getJsonString(obj), cls);
    }
}
